#include <stdio.h>
#include <ulib.h>
#include <file.h>
#include <unistd.h>

int
main(void) {
	cprintf("Hello world.\n");
	int* aaa = 0xAFFFFFFF;
	int i, j, k;
//	cprintf("%d\n", *aaa);

	int acc = open("/bet", O_WRONLY | O_CREAT);
	write(acc, "test file before checkpoint.\n", 31);

	int fde = open("/how", O_WRONLY | O_CREAT);
	int kw = checkpoint(0, fde, 3, -1);
		// test file

	if (kw == 0)
	{
		for (i = 0; i < 10; i++)
		{
			cprintf("hello world !!, I'm the restarted proc %d.\n", i);
			sleep(10);
		}

		write(acc, "task restarted..\n", 17);
		close(acc);

		return 0;

	}
	else
	{

		cprintf("Check_point over...\n");

		close(fde);
		close(acc);

		cprintf("CLose over...\n");

		return 0;
	}
}

